package com.android.powerbankpad;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.ws.universal.tools.base.BaseActivity;


/**
 * @author:ws
 * @date: 2020/10/26 9:18
 * @desc
 */
public class LauncherActivity extends AppCompatActivity {
    private Intent intent;
    private boolean isStartUp = false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        intent = getIntent();
        isStartUp = intent.getBooleanExtra("isStartUp", false);
        // 避免从桌面启动程序后，会重新实例化入口类的activity
        if (!this.isTaskRoot()) {
            Intent intent = getIntent();
            if (intent != null) {
                String action = intent.getAction();
                if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
                    finish();
                }
            }
        } else {
            intent = new Intent(LauncherActivity.this, MainActivity.class);
            intent.putExtra("isStartUp", isStartUp);
            startActivity(intent);
            finish();
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(intent!=null){
            intent = null;
        }
    }
}
